package ph.com.gs3.formalistics.annotations;

import java.lang.reflect.Method;

import ph.com.gs3.formalistics.model.dao.SQLiteDataAccessObject.DAOClosedException;
import android.database.sqlite.SQLiteDatabase;

public class DataAccessMethodParser {

	private SQLiteDatabase database;

	public DataAccessMethodParser(SQLiteDatabase database) {
		this.database = database;
	}

	public void parse(Class<?> dataAccessMethodClass) throws DAOClosedException {
		Method[] methods = dataAccessMethodClass.getMethods();

		for (Method method : methods) {
			if (method.isAnnotationPresent(DataAccessMethod.class)) {
				if (!this.database.isOpen()) {
					throw new DAOClosedException();
				}
			}
		}
	}

}
